import hashlib
import requests
import json
import time

params = {
"jsv": "2.6.1",
"appKey": "12574478",
"t": "1748407810437",
"api": "mtop.taobao.qianniu.number.get.new",
"v": "1.0",
"ttid": "11320@taobao_WEB_9.9.99",
"dataType": "originaljsonp",
"type": "originaljsonp",
"callback": "mtopjsonp39",
}
headers = {
"accept": "/",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
"referer": "https://qn.taobao.com/home.htm/QnworkbenchHome/",
"sec-ch-ua": '"Chromium";v="136", "Microsoft Edge";v="136", "Not.A/Brand";v="99"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"sec-fetch-dest": "script",
"sec-fetch-mode": "no-cors",
"sec-fetch-site": "same-site",
"cookie":"World_samesite_flag_= true;3PcFlag= 1754382688784;cookie2= 1a89de17f0285f4e975737f570f83d5c;t= cce14577b2d320f007de215b20639d30;_tb_token_= e11f33e188e88;cna= Yq8YITeYBWkBASQOBEglAX8D;xlly_s= 1;wk_cookie2= 1af012d48a003eeb08175c6a066d8cca;wk_unb= UUGmuDkupDWi0g%3D%3D;sgcookie= E1003RyWyW%2FumaDPxAf%2B%2B01KXtKFZTJZvwyycf6nWPDvkX0Mx401uHc1zRomp03WKUNBmgwcyHHdnyD1aHnDSIb1FljExJhAvMfDclP2p4OlAkz%2F8FngvCBC5axvKi1ni8o3;_hvn_lgc_= 0;havana_lgc2_0= eyJoaWQiOjI5NDY4MTYyMDIsInNnIjoiNTkzOWZjOTY5NDIwNjI0YWI2MzAyNmNkMzJiYTA0YzkiLCJzaXRlIjowLCJ0b2tlbiI6IjFta0lxbWVLdEZGaUNITHJubERGTTN3In0;unb= 2946816202;csg= 9695943b;lgc= %5Cu8C01%5Cu4E00%5Cu76F4%5Cu9519%5Cu8FC7%5Cu706C;cancelledSubSites= empty;cookie17= UUGmuDkupDWi0g%3D%3D;dnk= %5Cu8C01%5Cu4E00%5Cu76F4%5Cu9519%5Cu8FC7%5Cu706C;skt= 313ccdf3b55de904;tracknick= %5Cu8C01%5Cu4E00%5Cu76F4%5Cu9519%5Cu8FC7%5Cu706C;_l_g_= Ug%3D%3D;sg= %E7%81%AC2d;_nk_= %5Cu8C01%5Cu4E00%5Cu76F4%5Cu9519%5Cu8FC7%5Cu706C;cookie1= BxJI7OIsHKnyWIKpeEVfpiWULbWiaO8A7bT0P4rbCUA%3D;sn= ;existShop= MTc1NDM4MjcwMQ%3D%3D;uc4= id4=0%40U2OR8JKgWN66MnQwTOOUCnLWpbuG&nk4=0%40qj7YH9kLy2KODOM4PYhyi4C9%2F5U20wE%3D;uc1= cookie21=UIHiLt3xSift4ZS1LW77rg%3D%3D&pas=0&cookie14=UoYbz9imRYay9w%3D%3D&cookie16=UIHiLt3xCS3yM2h4eKHS9lpEOw%3D%3D&existShop=true&cookie15=VT5L2FSpMGV7TQ%3D%3D;uc3= vt3=F8dD2fngziJQWe%2BCVIE%3D&nk2=qAV8EDuaEFSIkZAn&id2=UUGmuDkupDWi0g%3D%3D&lg2=U%2BGCWk%2F75gdr5Q%3D%3D;_cc_= VT5L2FSpdA%3D%3D;havana_lgc_exp= 1785486701720;tfstk= gNwE0baB89BEHFL1dPHyuHTLsIMKeY7fr8gSquqoA203A6hlzrZmZXZoPYzzzzuIZwHQUPz7q4gnRMhkZya8OX259gSrSueQOu1KZTzi7eZCyJ9rqVqoVWwz2LouqzIKPMC_vkH-EZ_jUtZLv7CB75QsEgqiF0-Anil8vkHJXZ_fhtZp4_9yd7DurAci2mkorzmlbVmrDQY3rYjNbVnoEbCL2GriW0DorzDlbl0tqbdLrypZ7XjiUoaFXSoETqqnSkZQID8jok0wELjSYXc_xVJkERFPKEkK-sKsyvgLADzRHpHnaSES4yWeKzrYBPogoTJj-lEbGXehNKGqd2l7Kk7FUlyr8j2n_39b0YmurbPOuKiEd5l4LWIJSk4j8SDLVn7QbjPZMccM4BDQGow-iJXekVGx4yg_otvZIbjPeUnGh728TUAotcnZlGSZxP1qRfxYGcAJwf5tbqsADQd-TgnZlG96wQhQkcuff11..;mtop_partitioned_detect= 1;_m_h5_tk= 80a2288ddcffc6120235ae9764a396d0_1754390628312;_m_h5_tk_enc= 91a78cc34a855a9a9924d9c6c32dc9d1",
"user-agent": "Mozilla/5.0 (Windows NT 10.0Win64x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0"
}
tokens = {item.split("=")[0]: item.split("=")[1] for item in headers.get("cookie").split(";")}
print(tokens.get("_m_h5_tk"))
token = tokens.get("_m_h5_tk").split("_")[0]
params["t"] = str(int(time.time() * 1000))
params["data"] = json.dumps({"fields": {"sycm-payAmt": {"today": "sycm.payAmt", "yday": ""}, "sycm-uv": {"today": "sycm.uv", "yday": ""}, "sycm-ord": {"today": "sycm.payOrdCnt", "yday": ""}, "sycm-payRate": {"today": "sycm.payRate", "yday": ""}, "sycm-pv": {"today": "sycm.pv", "yday": ""}, "sycm-cartByrCnt": {"today": "sycm.cartByrCnt", "yday": ""}, "sycm-payPct": {"today": "sycm.payPct", "yday": ""}, "sycm-payByrCnt": {"today": "sycm.payByrCnt", "yday": ""}, "sycm-amount": {"today": "sycm.amount", "yday": ""}, "sycm-transitOrderCnt": {"today": "sycm.transitOrderCnt", "yday": ""}, "sycm-revenueCnt": {"today": "sycm.revenueCnt", "yday": ""}, "sycm-costCnt": {"today": "sycm.costCnt", "yday": ""}}}, ensure_ascii=False).replace(" ", "")
params["sign"] = hashlib.md5(("%s&%s&12574478&%s" % (token, params["t"], params["data"])).encode('utf-8')).hexdigest()
res = requests.get("https://h5api.m.taobao.com/h5/mtop.taobao.qianniu.number.get.new/1.0/",params=params,headers=headers)
print(res.text)
